#ifndef BOOKMARK_H
#define BOOKMARK_H

#include "ICodeEditor.h"

#include <QIcon>
#include <QTextBlock>
#include <QFileInfo>

namespace Bookmarks {

class BookmarkManager;

class Bookmark : public CodeEdit::ITextMark
{
    Q_OBJECT

public:
    Bookmark(const QString &fileName, int lineNumber, BookmarkManager *manager);

    // ITextMark
    // returns bookmark icon
    virtual QIcon icon() const;
    // called if the lineNumber changes
    virtual void updateLineNumber(int lineNumber);
    // called whenever the text of the block for the marker changed
    virtual void updateBlock(const QTextBlock &block);
    // called if the block containing this mark has been removed
    // if this also removes your mark call this->deleteLater();
    virtual void removeFromEditor();
    virtual void documentClosing();

    inline QString filePath() const { return _fileName; }
    inline QString fileName() const { return QFileInfo(_fileName).fileName(); }
    inline QString path() const { return QFileInfo(_fileName).path(); }
    inline QString lineText() const { return _lineText; }

    inline int lineNumber() const { return _lineNumber; }

private:
    static QIcon __bookmarkIcon;

    BookmarkManager *_manager;
    QString _fileName;
    int _lineNumber;
    QString _lineText;
};

} // namespace Bookmarks

#endif // BOOKMARK_H
